import { computed } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', () => {
  const userData = computed(() => {
    return JSON.parse(localStorage.getItem('userData') || '{}')
  })

  const userRole = computed(() => {
    return userData.value && userData.value.highest_role_name ? userData.value.highest_role_name : null
  })

  const isLogined = computed(() => {
    return userData.value
  })

  return {
    userData,
    userRole,
    isLogined,
  }
})
